home *** CD-ROM | disk | FTP | other *** search
/ PC Direct 1998 August / PC Direct August 1998.iso / S / powerj / Product / hpp.z / WBASECL.HPP < prev    next >
Encoding:
C/C++ Source or Header  |  1997-11-25  |  3.4 KB  |  101 lines

  1. /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  2.    %     Copyright (C) 1994, by WATCOM International Inc.  All rights    %
  3.    %     reserved.  No part of this software may be reproduced or        %
  4.    %     used in any form or by any means - graphic, electronic or       %
  5.    %     mechanical, including photocopying, recording, taping or        %
  6.    %     information storage and retrieval systems - except with the     %
  7.    %     written permission of WATCOM International Inc.                 %
  8.    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  9. */
  10.  
  11. #ifndef _WBASECL_HPP_INCLUDED
  12. #define _WBASECL_HPP_INCLUDED
  13. #pragma once
  14.  
  15. #ifndef _WNO_PRAGMA_PUSH
  16. #pragma pack(push,8);
  17. #pragma enum int;
  18. #endif
  19.  
  20. #ifndef _WCHAR_HPP_INCLUDED
  21. #include "wchar.hpp"
  22. #endif
  23.  
  24. typedef unsigned long WClassID;
  25.  
  26. #define WDeclareName(c) \
  27.     public: \
  28.         virtual const WChar* GetClassName() const;
  29.  
  30. #define WDefineName(c) \
  31.         virtual const WChar* c::GetClassName() const { return WTEXT( #c ); }
  32.  
  33.  
  34.  
  35. #define WDeclareCommon(c) \
  36.     public:\
  37.         static WClassID ClassID(); \
  38.         virtual WClassID GetClassID() const; \
  39.         virtual WBool IsInstanceOf( WClassID id ) const; \
  40.         virtual WBool IsInstanceOf( const WChar *classname ) const;
  41.            
  42. #define WDefineCommon(c) \
  43.         static WClassID c::ClassID() \
  44.            { static WClassID id = 0; \
  45.              extern WClassID WEXPORT WGetClassID( const WChar *name );\
  46.              if( !id ) id = WGetClassID( WTEXT( #c ) );\
  47.              return( id ); }\
  48.         virtual WClassID c::GetClassID() const { return c::ClassID(); }\
  49.         virtual WBool c::IsInstanceOf( WClassID id ) const \
  50.            { return( id == c::ClassID() ); } \
  51.         virtual WBool c::IsInstanceOf( const WChar *classname ) const \
  52.            { extern WClassID WEXPORT WGetClassID( const WChar *name );\
  53.              return IsInstanceOf( WGetClassID( classname ) ); }
  54.  
  55.  
  56.  
  57. #define WDeclareSubclass(c,p) \
  58.         \
  59.         WDeclareName(c) \
  60.         WDeclareCommon(c) \
  61.     public:\
  62.         virtual WBool IsDerivedFrom( WClassID id ) const; \
  63.         virtual WBool IsDerivedFrom( const WChar *classname ) const;
  64.  
  65. #define WDefineSubclass(c,p) \
  66.         \
  67.         WDefineName(c) \
  68.         WDefineCommon(c) \
  69.         virtual WBool c::IsDerivedFrom( WClassID id ) const \
  70.            { return (WBool)( ( id == c::ClassID() ) ? 1 : p::IsDerivedFrom( id ) ); } \
  71.         virtual WBool c::IsDerivedFrom( const WChar *classname ) const \
  72.            { extern WClassID WEXPORT WGetClassID( const WChar *name );\
  73.              return IsDerivedFrom( WGetClassID( classname ) ); } 
  74.  
  75.  
  76. #define WDeclareRoot(c) \
  77.         \
  78.         WDeclareName(c)\
  79.         WDeclareCommon(c) \
  80.     public:\
  81.         virtual WBool IsDerivedFrom( WClassID ) const;\
  82.         virtual WBool IsDerivedFrom( const WChar *classname ) const;
  83.  
  84. #define WDefineRoot(c) \
  85.         \
  86.         WDefineName(c)\
  87.         WDefineCommon(c) \
  88.         virtual WBool c::IsDerivedFrom( WClassID id ) const \
  89.            { return (WBool)( id == c::ClassID() ); } \
  90.         virtual WBool c::IsDerivedFrom( const WChar *classname ) const \
  91.            { extern WClassID WEXPORT WGetClassID( const WChar *name );\
  92.              return IsDerivedFrom( WGetClassID( classname ) ); } 
  93.  
  94.  
  95. #ifndef _WNO_PRAGMA_PUSH
  96. #pragma enum pop;
  97. #pragma pack(pop);
  98. #endif
  99.  
  100. #endif // _WCLASS_HPP_INCLUDED
  101.